//
//  ViewController.m
//  06-UINavgationController
//
//  Created by dllo on 16/7/21.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "PushViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // 设置navgationBar的属性
    self.title = @"高雅馨吃药";
    self.navigationItem.title = @"GYX";
    // titleView
    UISegmentedControl *seg = [[UISegmentedControl alloc] initWithItems:@[@"韩旭", @"翻墙"]];
    seg.frame = CGRectMake(0, 0, 100, 44);
    // 标题视图 修改x, y对视图本身位置没有影响
    self.navigationItem.titleView = seg;
    // 3 legtBarButtonItem
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"SHUIBEI" style:UIBarButtonItemStylePlain target:self action:@selector(comeBack:)];
    // 4 rightBarButtonItem
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add:)];
    // 5 leftBarButtonItems
    // 6 rightBarButtonItems
    // barButtonItems数组中放1-2个Item为最优
    // 7 隐藏navgationBar
    self.navigationController.navigationBar.hidden = NO;
    self.navigationController.navigationBarHidden = NO;
    // 8 navgationBar背景样式
//    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    // 9 navgationBar的背景颜色
//    self.navigationController.navigationBar.backgroundColor = [UIColor blueColor];
    // 10 barTintColor Bar的颜色
//    self.navigationController.navigationBar.barTintColor = [UIColor redColor];
    // 11 tintColor Bar上元素的颜色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    // 12 translucent
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 200, 200);
    button.backgroundColor = [UIColor cyanColor];
    [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    // translucent 管理半透明效果 YES为开启(默认为YES) NO为关闭
    // 设置为YES时 self.view坐标系从原点开始
    // 设置为NO时 self.view坐标系navigationBar下开始
//    self.navigationController.navigationBar.translucent = NO;
    // 13 改变坐标效果, 与translucent为NO时效果一样
    self.edgesForExtendedLayout = UIRectEdgeNone;
#pragma mark - 页面跳转相关
    // 1 push 入栈
    // 2 pop 出栈
    // 3 viewControllers存放navigationController里所有的控制器
//    self.navigationController.viewControllers
    // 4 topViewController 栈顶视图控制器(最后入栈的)
    // 5 visibleViewController
    
}

- (void)buttonClicked:(UIButton *)button {
    // 将视图控制器入栈
    [self.navigationController pushViewController:[[PushViewController alloc] init] animated:YES];
}

- (void)add:(UIBarButtonItem *)barButton {
    NSLog(@"add");
}

- (void)comeBack:(UIBarButtonItem *)barButton {
    NSLog(@"返回");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
